package com.ruoyi.project.instrument.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.instrument.domain.InsCalibrationDataList;
import com.ruoyi.project.instrument.service.IInsCalibrationDataListService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 试剂定标记录详细Controller
 *
 * @author taney
 * @date 2021-06-03
 */
@AllArgsConstructor
@RestController
@RequestMapping("/instrument/calibrationDataList" )
public class InsCalibrationDataListController extends BaseController {

    private final IInsCalibrationDataListService iInsCalibrationDataListService;

    /**
     * 查询试剂定标记录详细列表
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:list')")
    @GetMapping("/list")
    public TableDataInfo list(InsCalibrationDataList insCalibrationDataList)
    {
        startPage();
        LambdaQueryWrapper<InsCalibrationDataList> lqw = new LambdaQueryWrapper<InsCalibrationDataList>();
        if (insCalibrationDataList.getCalibrationDataId() != null){
            lqw.eq(InsCalibrationDataList::getCalibrationDataId ,insCalibrationDataList.getCalibrationDataId());
        }
        if (insCalibrationDataList.getConcentration() != null){
            lqw.eq(InsCalibrationDataList::getConcentration ,insCalibrationDataList.getConcentration());
        }
        if (insCalibrationDataList.getTransmissionValues() != null){
            lqw.eq(InsCalibrationDataList::getTransmissionValues ,insCalibrationDataList.getTransmissionValues());
        }
        if (insCalibrationDataList.getScatteringValues() != null){
            lqw.eq(InsCalibrationDataList::getScatteringValues ,insCalibrationDataList.getScatteringValues());
        }
        List<InsCalibrationDataList> list = iInsCalibrationDataListService.list(lqw);
        return getDataTable(list);
    }

    /**
     * 导出试剂定标记录详细列表
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:export')" )
    @Log(title = "试剂定标记录详细" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(InsCalibrationDataList insCalibrationDataList) {
        LambdaQueryWrapper<InsCalibrationDataList> lqw = new LambdaQueryWrapper<InsCalibrationDataList>(insCalibrationDataList);
        List<InsCalibrationDataList> list = iInsCalibrationDataListService.list(lqw);
        ExcelUtil<InsCalibrationDataList> util = new ExcelUtil<InsCalibrationDataList>(InsCalibrationDataList. class);
        return util.exportExcel(list, "calibrationDataList" );
    }

    /**
     * 获取试剂定标记录详细详细信息
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Integer id) {
        return AjaxResult.success(iInsCalibrationDataListService.getById(id));
    }

    /**
     * 新增试剂定标记录详细
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:add')" )
    @Log(title = "试剂定标记录详细" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InsCalibrationDataList insCalibrationDataList) {
        return toAjax(iInsCalibrationDataListService.save(insCalibrationDataList) ? 1 : 0);
    }

    /**
     * 修改试剂定标记录详细
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:edit')" )
    @Log(title = "试剂定标记录详细" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InsCalibrationDataList insCalibrationDataList) {
        return toAjax(iInsCalibrationDataListService.updateById(insCalibrationDataList) ? 1 : 0);
    }

    /**
     * 删除试剂定标记录详细
     */
    @PreAuthorize("@ss.hasPermi('instrument:calibrationDataList:remove')" )
    @Log(title = "试剂定标记录详细" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(iInsCalibrationDataListService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
